// const componentModules = import.meta.globEager('/src/views/**/*.vue') // 立即引入
const componentModules = import.meta.glob('/src/views/**/*.vue') // 懒加载

import { RouteRecordRaw } from 'vue-router'
// import EmptyView from '/src/views/components/empty-view.vue'

function _importView(_path:string){
  return componentModules[`/src/views/${_path}`]
}

const routes :Array<RouteRecordRaw> = [
    { path: '/', redirect: '/home' },
    { path: '/home', component: _importView('Hi.vue') },
    // ========
    // { path: "/404", name: "notFound", component: _importView('home.vue') },
    { path: "/404", name: "notFound", redirect: '/home' },
    {
      path: "/:pathMatch(.*)", // 此处需特别注意置于最底部
      redirect: "/404",
    }
  ]

export default routes